#include <stdio.h>
#include <mysql/mysql.h>

int main(int argc, char const *argv[])
{
    // 定义数据库的结构体变量
    MYSQL db;
    mysql_init(&db);  // 初始化数据库

    // 连接数据库
    /*
    MYSQL *		STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
					   const char *user,
					   const char *passwd,
					   const char *db,
					   unsigned int port,
					   const char *unix_socket,
					   unsigned long clientflag);
    
    */
    if(mysql_real_connect(&db, "localhost","root", "root", "mysql", 3306, NULL, 0) != NULL){
        printf("mysql connected!\n");

        mysql_close(&db);
    }

    return 0;
}
